<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/js/ext/resources/css/ext-all.css"/>

    <script type="text/javascript" src="<?php echo base_url(); ?>assets/js/ext/adapter/ext/ext-base.js"; ?>"></script>
    <script type="text/javascript" src="<?php echo base_url(); ?>assets/js/ext/ext-all.js"; ?>"></script>
    <script type="text/javascript" src="<?php echo base_url(); ?>assets/js/ext/ext-lang-es.js"></script>
    <script type="text/javascript" src="<?php echo base_url(); ?>assets/js/ext/plugins/searchfield.js"; ?>"></script>
    <script type="text/javascript">
    var BASE_URL = '<?php echo base_url(); ?>' + 'index.php/';
    var BASE_PATH = '<?php echo base_url(); ?>';
    var BASE_ICONS = BASE_PATH + 'assets/icons/';
    var RUT = '<?php echo $rut;?>';
    
    Ext.onReady(function() {
       
        var strUsers = new Ext.data.Store({
            reader: new Ext.data.JsonReader({
                fields: [
							'idProveedor', 'razon_social', 'nombre_fantasia', 'rut', 'giro', 'direccion', 'telefono',
							 'email', 'plazo_pago','nombre_ventas', 'cargo_ventas', 'fono_ventas', 'email_ventas',
							 'nombre_contabilidad', 'cargo_contabilidad','fono_contabilidad', 'email_contabilidad'
                         ],
                root: 'rows',
                totalProperty: 'results'
            }),
            proxy: new Ext.data.HttpProxy({
                url: BASE_URL + 'proveedor/getFichaProveedor/'+ RUT +'',
                method: 'POST'
            })
        });

        var strProducto = new Ext.data.Store({
            reader: new Ext.data.JsonReader({
                fields: [
                    'idProducto', 'producto'
                ],
                root: 'rows', totalProperty: 'results'
            }),
            proxy: new Ext.data.HttpProxy({
                url: BASE_URL + 'producto/productoSelect',
                method: 'POST'
            })
        });
        

        function estiloCelda(val) {	
            return '<b>' + val  +'</b>';
        } 

        
        var gridUsers = new Ext.grid.EditorGridPanel({
            title: 'Ficha Proveedor'+
                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+                   
                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+ 
                   '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+                   
                   '<a href="javascript:history.go(-1)">Volver</a>',
            store: strUsers, 
            style: 'margin:0 auto;', height: 75, width: 805,
            columns: [{
                header: "Rut",
                dataIndex: 'rut',
                sortable: true,
                width: 200,
                renderer: estiloCelda
            },{
                header: "Nombre Fantas&iacute;a",
                dataIndex: 'nombre_fantasia',
                sortable: true,
                width: 200,
                renderer: estiloCelda
            },{
                header: "Raz&oacute;n Social",
                dataIndex: 'razon_social',
                sortable: true,
                width: 200,
                renderer: estiloCelda
            },{
                    header: "Giro",
                    dataIndex: 'giro',
                    sortable: true,
                    width: 200,
                    renderer: estiloCelda
                }
            ]
        });

        var gridUsers2 = new Ext.grid.EditorGridPanel({
            store: strUsers, 
            style: 'margin:0 auto;', height: 50, width: 805,
            columns: [ {
                header: "Direcci&oacute;n",
                dataIndex: 'direccion',
                sortable: true,
                width: 200,
                renderer: estiloCelda
            },{
                header: "Tel&eacute;fono",
                dataIndex: 'telefono',
                sortable: true,
                width: 200,
                renderer: estiloCelda
            },{
                    header: "Email",
                    dataIndex: 'email',
                    sortable: true,
                    width: 200,
                    renderer: estiloCelda
                },{
                    header: "Plazo Pago",
                    dataIndex: 'plazo_pago',
                    sortable: true,
                    width: 200,
                    renderer: estiloCelda
                }
            ]
        });

        var gridUsers3 = new Ext.grid.EditorGridPanel({
            store: strUsers, 
            style: 'margin:0 auto;', height: 50, width: 805,
            columns: [ {
                header: "Nombre Ventas",
                dataIndex: 'nombre_ventas',
                sortable: true,
                width: 200,
                renderer: estiloCelda
            },{
                header: "Cargo Ventas",
                dataIndex: 'cargo_ventas',
                sortable: true,
                width: 200,
                renderer: estiloCelda
            },{
                header: "Tel&eacute;fono Ventas",
                dataIndex: 'telefono_ventas',
                sortable: true,
                width: 200
            },{
                header: "Email Ventas",
                dataIndex: 'email_ventas',
                sortable: true,
                width: 200,
                renderer: estiloCelda
            }
            ]
        });

        var gridUsers4 = new Ext.grid.EditorGridPanel({
            store: strUsers, 
            style: 'margin:0 auto;', height: 50, width: 805,
            columns: [ {
                header: "Nombre Contabilidad",
                dataIndex: 'nombre_contabilidad',
                sortable: true,
                width: 200,
                renderer: estiloCelda
            },{
                    header: "Cargo Contabilidad",
                    dataIndex: 'cargo_contabilidad',
                    sortable: true,
                    width: 200,
                    renderer: estiloCelda
                },{
                    header: "Tel&eacute;fono Contabilidad",
                    dataIndex: 'fono_contabilidad',
                    sortable: true,
                    width: 200,
                    renderer: estiloCelda
                },{
                    header: "Email Contabilidad",
                    dataIndex: 'email_contabilidad',
                    sortable: true,
                    width: 200,
                    renderer: estiloCelda
                }
            ]
        });

        var gridUsersListaProductos = new Ext.grid.EditorGridPanel({
            title: 'Listado de Productos Gen&eacute;ricos',
            store: strProducto, 
            style: 'margin:0 auto;', height: 500, width: 805,
            columns: [{
                header: "Producto",
                dataIndex: 'producto',
                sortable: true,
                width: 300,
                renderer: estiloCelda
            },{
                header: "Costo",
                dataIndex: 'costo',
                sortable: true,
                width: 100,
                renderer: estiloCelda
            }
            ]
        });   

        gridUsers.render('divgrid');
        gridUsers2.render('divgrid2');
        gridUsers3.render('divgrid3');
        gridUsers4.render('divgrid4');
        strUsers.load();
        gridUsersListaProductos.render('divgrid6');
        strProducto.load();
                   
    });
    </script>
    <style type="text/css">
        
    </style>

    <title></title>
</head>
<body>
    <div id="divgrid"></div>
    <div id="divgrid2"></div>
    <div id="divgrid3"></div>
    <div id="divgrid4"></div>
    <div id="divgrid5"></div>
    <br/>
    <div id="divgrid6"></div>
</body>
</html>